package com.fwtai.controller.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.service.web.ProfileService;
import com.fwtai.tool.ToolClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 个人中心
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2022-11-30 14:15
 * @QQ号码 444141300
 * @Email service@dwlai.com
 * @官网 http://www.fwtai.com
 */
@RestController
@RequestMapping("/profile")
public class ProfileController{

  private final ProfileService profileService;

  public ProfileController(final ProfileService profileService){
    this.profileService = profileService;
  }

  /**自行修改密码*/
  @PostMapping("/editPassword")
  @PreAuthorize("hasAuthority('profile_btn_password')")
  public void editPassword(final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(profileService.editPassword(new PageFormData(request)),response);
  }
}